<header id="topbar" class="affix">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="<%= window.location.href %>">上分通道详情</a>
            </li>
            <li class="crumb-link">
                <a href="#op/channel/">通道管理</a>
            </li>
            <li class="crumb-trail">通道编辑</li>
        </ol>
    </div>
    <div class="pull-right">
        <a href="javascript:;" class="btn btn-primary btn-sm light fw600 ml10 template-save"><span class="fa fa-save"></span>保存</a>
    </div>
</header>
<section id="content">
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">参数设置</span>
        </div>
        <div class="panel-body">
            <form id="template-form" class="form-horizontal">
                <div class="form-group">
                    <label for="inputName" class="col-md-2 control-label">通道名称：</label>
                    <div class="col-md-8">
                        <input type="text" id="inputName" class="form-control" value="<%= info.name %>" placeholder="请输入通道名称..." required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputMchId" class="col-md-2 control-label">商户编号：</label>
                    <div class="col-md-8">
                        <select class="required form-control search-select" id="inputMchId">
                            <% _.each(mchs, function(mch){ %>
                                <option value="<%= mch.id %>" <%= info.mch_id == mch.id ? 'selected' : '' %>><%= mch.name %>(<%= mch.id %>)</option>
                            <% }) %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputChnType" class="col-md-2 control-label">通道类型：</label>
                    <div class="col-md-8">
                        <select class="required form-control search-select" id="inputChnType">
                            <% _.each(CHANNEL_TYPE, function(v, k){ %>
                                <option value="<%= k %>" <%= info.chn_type == k ? 'selected' : '' %>><%= v %></option>
                            <% }) %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputOpenType" class="col-md-2 control-label">唤起支付方式：</label>
                    <div class="col-md-8">
                        <select class="required form-control search-select" id="inputOpenType">
                            <% _.each(OPEN_TYPE, function(open_type){ %>
                                <option value="<%= open_type %>" <%= info.open_type == open_type ? 'selected' : '' %>><%= open_type %></option>
                            <% }) %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputServiceName" class="col-md-2 control-label">支付分类：</label>
                    <div class="col-md-8">
                        <select class="required form-control search-select" id="inputServiceName">
                            <% if(info.service_name){ %>
                                <option value="<%= info.service_name %>" selected><%= info.service_name %></option>
                            <% } else { %>
                            <% _.each(SERVICE_NAME, function(service_name){ %>
                                <option value="<%= service_name %>" <%= info.service_name == service_name ? 'selected' : '' %>><%= service_name %></option>
                            <% })} %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputInfo" class="col-md-2 control-label">通道参数：</label>
                    <div class="col-md-8">
                    <textarea id="inputInfo" class="form-control" value="<%= info.info %>" placeholder="请输入通道参数，json格式" required>
                    <%= info.info %>
                    </textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputStatus" class="col-md-2 control-label">通道状态：</label>
                    <div class="col-md-8">
                        <select class="required form-control search-select" id="inputStatus">
                            <% _.each(CHANNEL_STATUS, function(v, k){ %>
                                <option value="<%= k %>" <%= info.status == k ? 'selected' : '' %>><%= v %></option>
                            <% }) %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputWeight" class="col-md-2 control-label">权重：</label>
                    <div class="col-md-8">
                        <input id="inputWeight" type="number" min="0" max="1000" class="form-control" value="<%= info.weight %>" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputLevel" class="col-md-2 control-label">等级：</label>
                    <div class="col-md-8">
                        <input id="inputLevel" type="number" min="0" max="1000" class="form-control" value="<%= info.level %>" required>
                    </div>
                </div>
                <% if(info.info){ %>
                    <% var infoObject = eval('(' + info.info + ')'); %>
                    <% var hourly_amount = -1; %>
                    <% var daily_amount = -1; %>
                    <% var start_time = -1; %>
                    <% var end_time = -1; %>
                    <% if(infoObject.incr_risk && infoObject.incr_risk.hourly && infoObject.incr_risk.hourly.amount){hourly_amount = infoObject.incr_risk.hourly.amount} %>
                    <% if(infoObject.incr_risk && infoObject.incr_risk.daily && infoObject.incr_risk.daily.amount){daily_amount = infoObject.incr_risk.daily.amount} %>
                    <% if(infoObject.daily_open_time && (infoObject.daily_open_time.start || infoObject.daily_open_time.start == 0)){start_time = infoObject.daily_open_time.start} %>
                    <% if(infoObject.daily_open_time && (infoObject.daily_open_time.end || infoObject.daily_open_time.end == 0)){end_time = infoObject.daily_open_time.end} %>
                    <div class="form-group">
                        <label for="inputHourMoney" class="col-md-2 control-label">每小时限额(元)：</label>
                        <div class="col-md-8">
                            <input id="inputHourMoney" type="number" min="0" class="form-control" value="<%= hourly_amount %>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputDailyMoney" class="col-md-2 control-label">每天限额(元)：</label>
                        <div class="col-md-8">
                            <input id="inputDailyMoney" type="number" min="0" class="form-control" value="<%= daily_amount %>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputDailyStart" class="col-md-2 control-label">每天开始时间(0~24h)：</label>
                        <div class="col-md-8">
                            <input id="inputDailyStart" type="number" min="-1" class="form-control" value="<%= start_time %>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputDailyEnd" class="col-md-2 control-label">每天结束时间(0~24h)：</label>
                        <div class="col-md-8">
                            <input id="inputDailyEnd" type="number" min="-1" class="form-control" value="<%= end_time %>" required>
                        </div>
                    </div>
                <% } %>
            </form>
        </div>
    </div>

</section>
